// Copyright (c) MatrixFramework. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System;

namespace Matrix.ServiceCommunication.Monitoring;

/// <summary>
/// 服务通信指标接口
/// </summary>
public interface IServiceCommunicationMetrics
{
    /// <summary>
    /// 记录HTTP请求指标
    /// </summary>
    /// <param name="serviceName">服务名称</param>
    /// <param name="method">HTTP方法</param>
    /// <param name="statusCode">状态码</param>
    /// <param name="duration">持续时间（毫秒）</param>
    void RecordRequest(string serviceName, string method, int statusCode, double duration);

    /// <summary>
    /// 增加活跃请求数
    /// </summary>
    /// <param name="serviceName">服务名称</param>
    void IncrementActiveRequests(string serviceName);

    /// <summary>
    /// 减少活跃请求数
    /// </summary>
    /// <param name="serviceName">服务名称</param>
    void DecrementActiveRequests(string serviceName);

    /// <summary>
    /// 记录认证成功
    /// </summary>
    /// <param name="authType">认证类型</param>
    /// <param name="serviceName">服务名称</param>
    void RecordAuthenticationSuccess(string authType, string serviceName);

    /// <summary>
    /// 记录认证失败
    /// </summary>
    /// <param name="authType">认证类型</param>
    /// <param name="serviceName">服务名称</param>
    /// <param name="errorType">错误类型</param>
    void RecordAuthenticationFailure(string authType, string serviceName, string errorType);

    /// <summary>
    /// 记录服务发现操作
    /// </summary>
    /// <param name="operation">操作类型</param>
    /// <param name="serviceName">服务名称</param>
    /// <param name="success">是否成功</param>
    /// <param name="duration">持续时间（毫秒）</param>
    void RecordServiceDiscoveryOperation(string operation, string serviceName, bool success, double duration);

    /// <summary>
    /// 记录容错策略触发
    /// </summary>
    /// <param name="strategy">策略类型</param>
    /// <param name="serviceName">服务名称</param>
    /// <param name="success">是否成功</param>
    void RecordResilienceStrategy(string strategy, string serviceName, bool success);
}